# connect to database
con1 <- connectToVadb(dbname="va_wikifolio")
con2 <- connectToVadb()

sqlcmd <-"SELECT `id`, `symbol`, `name` FROM stockname"
stocksym <- dbGetQuery(con1, sqlcmd)
stocksym[,4] <-""

for (i in 1:nrow(stocksym)) {
  sqlcmd <- sprintf("SELECT `name` FROM stockname WHERE `code`='%s'", stocksym[i,"symbol"])
  vadbsym <- dbGetQuery(con2, sqlcmd)
  if (nrow(vadbsym)>0) {
    #print(vadbsym[,1])
    stocksym[i,4] <- paste(vadbsym[1,1], vadbsym[2,1])
  }
}

stocksym

disconnectFromVadb(con1)
disconnectFromVadb(con2)